<?php include '../public/header.php' ?>
<?php include '../public/header_public.php' ?>
<style>
    #curmsg{position: relative;top: -29px;left: 150px;height: 0;}
</style>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title pagetit">监理日志</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">日期</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="dt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">填报人</label>
                        <div class="layui-input-block">
                            <input type="text" name="created_user_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <input type="hidden" id="status" name="status">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
<!--                                <div id="search_open" onclick="toggle_search()">-->
<!--                                    <i class="layui-icon layui-icon-down"></i>展开-->
<!--                                </div>-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <?php include 'dao.php' ?>
            <div class="layui-col-md10" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
    <div id="curmsg">日志应报未报数量：<span id="bao_no">0</span></div>
</script>
<script>

    var param_enginid = getQueryVariable('id') || 0;
    var param_enginname = decodeURI(getQueryVariable('name')) || '';
    $(".pagetit").html(param_enginname);

    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });


        setSouTableExport('监理日志');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_engin_jian_list),where: {enginid:param_enginid}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                $("#bao_no").html(res.data.bao_no);

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',fixed:'left'}
                ,list_status_cols_str
                ,{field: 'dt', title: '日期'}
                ,{field: 'enginname', title: '项目名称'}
                ,{field: 'title', title: '标题'}
                ,{field: 'gai', title: '监理概况'}
                ,{field: 'explain', title: '备注'}
                ,{field: 'created_user_name', title: '填报人'}
                ,{field: 'dealid_name', title: '填报单位'}
                ,{field: 'created_at', title: '填报时间'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){

                            if(currButAuth[key].butname == 'shen'){
                                if(!currTabData[index].isshen){
                                    continue;
                                }
                            }
                            if(currButAuth[key].butname == 'edit'){
                                if(currTabData[index].status != 9){
                                    continue;
                                }
                            }
                            if(currButAuth[key].butname == 'delete'){
                                if(currTabData[index].status == 1){
                                    if(currTabData[index].token_roletype > 1){
                                        continue;
                                    }
                                }
                            }

                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });
        listTableSearch(form, table);


    });


    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('show.php?id='+trData.id);
    }

    function auth_but_func_add(){
        openPageEdit('lan.php?close=1&enginid='+param_enginid, '770px', '690px');
    }
    function auth_but_func_edit(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('edit.php?close=1&id='+trData.id);
    }
    function auth_but_func_shen(buttitle, index){
        var trData = currTabData[index];
        openPage('show.php?id='+trData.id+'&shen=1');
    }
    function auth_but_func_delete(buttitle, index){
        var trData = currTabData[index];
        data_delete(ask_engin_jian_del, {id:trData.id});
    }





    function lanpage_0(dataid) {
        layer.closeAll();
        openPage('show.php?id='+dataid);
    }
    function lanpage_1(dataid) {
        layer.closeAll();
        openPage('show.php?id='+dataid);
    }
    function lanpage_9(dataid) {
        layer.closeAll();
        openPage('edit.php?id='+dataid);
    }
    function lanpage_7(enginid, dt) {
        layer.closeAll();
        openPage('add.php?enginid='+enginid+'&dt='+dt);
    }











    function layer_close(){
        try {
            parent.layui.table.reload('datalist');
        }catch (e) {

        }
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
</body>
</html>
